#ifndef __FILESYSTEM_H__
#define __FILESYSTEM_H__
#include <sched.h>

#define FILE_NAME_SIZE 10
#define MAX_FILES 10
#define MAX_BLOCKS 64
#define BLOCK_SIZE 256
#define OFT_SIZE 40
#define EOF -1

/* Flags */
#define O_RDONLY 0x01
#define O_WRONLY 0x02
#define O_RDWR 0x03
#define O_CREAT 0x04
#define O_EXCL 0x08

int FAT[MAX_BLOCKS];
int free_block;

char disk[MAX_BLOCKS][BLOCK_SIZE];

struct file_operations
{
	int (*sys_open_dev)(char*, int);
	int (*sys_close_dev)(int);
	int (*sys_read_dev)(char*, int, int);
	int (*sys_write_dev)(const char*, int, int);
	int (*sys_release_dev)(int);
} operations[MAX_FILES];

struct file
{
	char name[FILE_NAME_SIZE];
	int n_refs;
	int free;
	int access_mode;
	int fat_index;
	int size;
	struct file_operations *ops;
} directory[MAX_FILES];

/* Open File Table */
struct oft_entry
{
	int n_refs;
	int access_mode;
	int seek;
	struct file *f;
} oft[OFT_SIZE];

#endif
